<%@ page import="org.apache.commons.fileupload.FileItem" %>
      <%@ page import="java.util.List" %>
      <%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %>
      <%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload" %>
      <%@ page import="org.apache.commons.io.FilenameUtils" %>
      <%@ page import="java.io.File" %>
      <%@ page contentType="text/html;charset=GB2312" language="java"%>
<%
String filename = "";
String clientPath = "";
String redirectURL ="postUpload.brl";
try {

    //throw new Exception("some nodeid !");
    request.setCharacterEncoding( "GB2312" ); 
    if (ServletFileUpload.isMultipartContent(request)) {
	
	ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
	List<FileItem> fileItemsList = servletFileUpload.parseRequest(request);
	for (FileItem item : fileItemsList) {
		filename= item.getFieldName();
	    if (!item.isFormField()) {
		
		String _filename = item.getName();

		 clientPath = "dbk/" + filename+"/"+_filename; 
		File file = new File(application.getRealPath(clientPath));
		System.out.println(file.toString());

		if (!file.getParentFile().exists()) {
		    file.getParentFile().mkdirs();
		}
		item.write(file);
	    }
	}
	      }
    redirectURL += "?project=";
    redirectURL += filename;
    
    
} catch (Exception ee)
{
	System.out.println(ee.toString());
	redirectURL += "error=";
    redirectURL += ee.toString();
    
} finally {
    
//response.sendRedirect(redirectURL);
}

%>

